package com.hq.door.dto;

import java.util.ArrayList;
import java.util.List;

import com.hq.door.dao.TStudentDAO;
import com.hq.door.pojo.TClass;
import com.hq.door.pojo.TStudent;

public class StudentInfo {
	private int id;

	private String name;
	private String code;
	private String mobile;

	private String institutename;
	private String majorname;
	private String classname;
	private String grade;

	private String parentname;
	private String parentmobile;
	private String teachername;

	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getCode() {
		return code;
	}

	public void setCode(String code) {
		this.code = code;
	}

	public String getMobile() {
		return mobile;
	}

	public void setMobile(String mobile) {
		this.mobile = mobile;
	}

	public String getInstitutename() {
		return institutename;
	}

	public void setInstitutename(String institutename) {
		this.institutename = institutename;
	}

	public String getMajorname() {
		return majorname;
	}

	public void setMajorname(String majorname) {
		this.majorname = majorname;
	}

	public String getClassname() {
		return classname;
	}

	public void setClassname(String classname) {
		this.classname = classname;
	}

	public String getParentname() {
		return parentname;
	}

	public void setParentname(String parentname) {
		this.parentname = parentname;
	}

	public String getParentmobile() {
		return parentmobile;
	}

	public void setParentmobile(String parentmobile) {
		this.parentmobile = parentmobile;
	}

	public String getTeachername() {
		return teachername;
	}

	public void setTeachername(String teachername) {
		this.teachername = teachername;
	}

	public String getGrade() {
		return grade;
	}

	public void setGrade(String grade) {
		this.grade = grade;
	}

//	public void getStudentNameAndClass(TStudent tStudent) {
//		this.name = tStudent.getName();
//		this.code = tStudent.getCode();
//		this.classname = tStudent.getTClass().getName();
//		this.majorname = tStudent.getTClass().getTMajor().getName();
//		this.institutename = tStudent.getTClass().getTMajor().getTInstitute().getName();
//		this.grade = tStudent.getTClass().getGrade();
//		this.parentname = tStudent.getParentName();
//		this.parentmobile = tStudent.getParentMobile();
//		this.teachername = tStudent.getTClass().getTTeacher().getName();
//	}

	public void getStudentOne(TStudent tStudent) {
		this.name = tStudent.getName();
		this.code = tStudent.getCode();
		this.mobile = tStudent.getMobile();
		this.classname = tStudent.getTClass().getName();
		this.majorname = tStudent.getTClass().getTMajor().getName();
		this.institutename = tStudent.getTClass().getTMajor().getTInstitute().getName();
		this.grade = tStudent.getTClass().getGrade();
		if(!tStudent.getTParents().isEmpty()){
			this.parentname = tStudent.getTParents().iterator().next().getName();
			this.parentmobile = tStudent.getTParents().iterator().next().getCode();
		}
		if(tStudent.getTClass().getTTeacher()!=null)
			this.teachername = tStudent.getTClass().getTTeacher().getName();
	}

	public List<StudentInfo> getStudentByPage(List<TStudent> tStudents) {
		List<StudentInfo> studentInfos = new ArrayList<StudentInfo>();
		for (TStudent tStudent : tStudents) {
			StudentInfo e = new StudentInfo();
			e.getStudentOne(tStudent);
			studentInfos.add(e);
		}
		return studentInfos;
	}

	public void transformToTStudent(TStudent tStudent){
		tStudent.setName(this.name);
		tStudent.setMobile(this.mobile);
	}
}
